import java.util.*;

class Util {

  private Util() {}

  static Map<String,String> parseArgs(String s) {
    int ihuh = s.indexOf("?");
    if(ihuh != -1) s = s.substring(ihuh + 1);
    return genericParse(s, "&");
  }

  static boolean isEmpty(String s) {
    return s == null || s.equals("");
  }

  static String q(Object o) {
    final String s = o == null ? "" : String.valueOf(o);
    return "\"" + s.replaceAll("\"","\\\"") + "\"";
  }

  private static Map<String,String> genericParse(String rest, String delim) {
    Map<String,String> res = new HashMap<String,String>();
    if(isEmpty(rest))
      return res;
    String key;
    String val;
    for(StringTokenizer st = new StringTokenizer(rest, delim, false); 
        st.hasMoreTokens(); 
        res.put(key.trim(), val != null ? val.trim() : val)) {
      String pair = st.nextToken();
      int ieq = pair.indexOf('=');
      if(ieq == -1) {
        key = pair;
        val = null;
      } else {
        key = pair.substring(0, ieq);
        val = pair.substring(ieq + 1);
      }
    }

    return res;
  }

}
